package com.smartphonedev.function;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.telephony.SmsManager;
import android.util.Log;

import com.smartphonedev.service.AlarmService;

public class SmsFunc {

	public static void sendASms(final Context context, String number, String message)
	{        
		SmsManager sms = SmsManager.getDefault();
		try {
			sms.sendTextMessage(number, null, message, null, null);        
		} catch (Exception e) {
			Log.e("Error", "Message not sent");
		}
	}

	public static void startSMSAlert(Context context){
		PendingIntent mAlarmSender = PendingIntent.getService(context,
				0, new Intent(context, AlarmService.class), 0);
		long firstTime = SystemClock.elapsedRealtime();
		AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
		am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
				firstTime,30*60*1000 , mAlarmSender);  

	}

}
